package artist.graphic.cn.Utils;

import android.content.Context;
import android.text.TextUtils;
import android.widget.ImageView;

import com.squareup.picasso.Picasso;
import com.youth.banner.loader.ImageLoader;

/**
 * Created by wanghunlong on 2017/12/25.
 */

public class PicassoImageLoader extends ImageLoader {
    private int errDrawalbe = -1;
    public PicassoImageLoader(int errDrawalbe) {
        this.errDrawalbe = errDrawalbe;
    }

    @Override
    public void displayImage(Context context, Object path, ImageView imageView) {
        if (errDrawalbe == -1) {
            Picasso.with(context).load(path.toString()).into(imageView);
        } else {
            if (path == null || TextUtils.isEmpty(path.toString())) {
                imageView.setBackgroundResource(errDrawalbe);
            } else {
                Picasso.with(context).load(path.toString()).placeholder(errDrawalbe).error(errDrawalbe).into(imageView);
            }
        }
    }
}